﻿using System;
using System.Collections.Generic;
using System.Text;

namespace StandXunYouWeb.Utility
{
    /// <summary>
    /// 统一返回格式
    /// </summary>
    public class BaseState
    {
        /// <summary>
        /// 200 和 0 都是成功，因为Layui表格中需要返回0状态识别数据
        /// </summary>
        public int Code { get; set; }
        public string Msg { get; set; }
        public object Data { get; set; }
        public int Count { get; set; }

        public static BaseState CreateInstance(int Code= RequestSucces, string Msg= RequestSuccesMsg, object Data=null,int Count=0)
        {
            return new BaseState { Code = Code, Count = Count, Data = Data, Msg = Msg }; ;
        }

        //字段为空
        public const int RequestField = 203;
        public const string RequestFieldMsg = "验证不通过，请填写必填项！";


        //正常请求
        public const int RequestSucces = 200;
        public const string RequestSuccesMsg = "请求成功";

        //非法请求
        public const int RequestNonAuthor = 401;
        public const string RequestNonAuthorMsg = "所请求的资源无权限访问";


        //服务器异常
        public const int RequestFail = 500;
        public const string RequestFailMsg = "服务器异常，请稍后重试！";


        public const int RequestError = -1;


    }
}
